<div class="layui-row">
    <form class="layui-form">
        <div class="layui-inline">
            <label class="layui-form-label w-auto">短剧id：</label>
            <div class="layui-input-inline">
                <input type="text" name="video_id" placeholder="请输入短剧id" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label w-auto">短剧名称：</label>
            <div class="layui-input-inline">
                <input type="text" name="name" placeholder="请输入短剧名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <button class="layui-btn" style="margin-left: 10px;" lay-submit lay-filter="searchthirdVideo2">搜索</button>
    </form>
</div>

<table id="tx-video" lay-filter="tx-video"></table>


<script type="text/html" id="tx-tbBar">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="authorize">授权</a>
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="look">查看</a>

</script>

<script>
    let paramss = {
        elem: '#tx-video'
        , url: '/admin/thirdVideo/list?type=1' //数据接口
        , page: true //开启分页
        , id: 'tx-video'
        , limit: 15
        , cols: [[//表头
            { field: 'video_id', title: '短剧ID', width: 100, align: 'center' },
            {
                field: 'cover_img', title: '封面图片', width: 150, align: 'center',
                templet: function (d) {
                    if (d.cover_img) {
                        return `<div class="layer-photos"  style="cursor:pointer;height: 100%;">
                                    <img onclick="showimg(this)" style="height: 100%;" src=`+ d.cover_img + ` alt="">
                                </div>`;
                    } else {
                        return `<div>暂无照片</div>`
                    }
                }
            },
            { field: 'drama_id', title: '剧目ID', width: 180, align: 'center' },
            { field: 'name', title: '短剧名称',  align: 'center' },
            { field: 'sylloge', title: '集数', width: 120, align: 'center' },
            {
                field: 'is_authorize', title: '授权状态', width: 90, align: 'center',
                templet: function (d) {
                    return d.is_authorize == 1 ? '已授权' : '未授权';
                }
            },
            { align: 'center', toolbar: '#tx-tbBar', title: '操作',width: 300 }
        ]]
    }

    tableList(paramss)

    layui.use(['table', 'form'], function () {
        let table = layui.table;
        let form = layui.form;

        table.on('tool(tx-video)', function (obj) {
            var event = obj.event;
            switch (event) {
                case 'authorize':
                    AnyAjax('确认授权么？', '{:url("admin/mediaAssets/wechatAuthorize")}', { video_id: obj.data.video_id }, 'tx-video')
                    //console.log(obj.data.applet_ids)
                    //x_admin_show(`授权`, `./wx_authorize.html?id=${obj.data.video_id}&data=${obj.data.applet_ids}`, 650, 550);
                    break;
                case 'look':
                    x_admin_show(`查看目录（短剧id:${obj.data.video_id} 短剧名称:${obj.data.name}）`, `./wx_episodes.html?id=${obj.data.video_id}&video_name=${obj.data.name}`, 1150, 650, null);
                    break;
            }
        });

        form.on('submit(searchthirdVideo2)', function (data) {
            paramss.where = data.field
            tableList(paramss)
            return false
        })
    });
</script>